// 描述：与当前业务无关的 api

(function(KIT, RES) {
  if(!KIT.html) {
    KIT.html = {};
  }

  var E = rapid.html.Element,
    ButtonBuilder = rapid.html.ButtonBuilder;

  // 常量定义
  KIT.BD_COLOR = "r-bd-0-1";

  RES.URL_ROOT = "/sysadmin";
  RES.URL_API = RES.URL_ROOT + "/api";

  RES.ADMIN_USER_LOGIN_ID = "admin";
  RES.ADMIN_USER_ID = "1";
  RES.ADMIN_ROLE_ID = "";
  RES.SESSION_USER_ID = "";
  RES.SESSION_USER_NAME = "";

  //region --------------------> rapid.kit 扩展（注释第一行注明需要引用的其它库）
  (function() {

    //#region rapid.kit.fillView和rapid.kit.fillForm方法已过时，请及时更换DataView插件，或对控件逐一赋值。
    KIT.fillView = function(selector, data, defaultValue) {
      console.log("rapid.kit.fillView和rapid.kit.fillForm方法已过时，请及时更换DataView插件，或对控件逐一赋值。");

      defaultValue = rapid.isUndefined(defaultValue) ? "" : defaultValue;

      if(rapid.isEmpty(data)) {
        rapid(selector).find(".fn-item").children().each(function() {
          rapid(this).html(defaultValue).parent().removeAttr("title");

        });

      } else {
        var _value, _$s, _cls;

        rapid(selector).find(".fn-item").children().each(function() {
          _$s = rapid(this);
          _cls = _$s.attr("class");

          if(rapid.isEmpty(_cls)) {
            return true;
          }

          _value = rapid.json.get(data, _cls);

          if(rapid.isDefined(_value)) {
            _$s.html(rapid.nvl(_value, defaultValue)).parent().attr("title", _value);
          } else {
            _$s.html("").parent().removeAttr("title");
          }
        });
      }

      return this;
    };
    KIT.fillForm = function(selector, data, filter, defaultValue) {
      console.log("rapid.kit.fillView和rapid.kit.fillForm方法已过时，请及时更换DataView插件，或对控件逐一赋值。");

      var _$s, _$inputs = rapid(selector).find(":input");

      if(rapid.isFunction(filter)) {
        _$inputs = _$inputs.map(filter);
        defaultValue = rapid.isUndefined(defaultValue) ? "" : defaultValue;

      } else if(rapid.isString(filter)) {
        defaultValue = filter;

      } else {
        defaultValue = "";
      }

      var __r_ui;

      if(rapid.isEmpty(data)) {
        _$inputs.each(function() {
          _$s = rapid(this);

          if(_$s.hasClass("r-value")) {

            __r_ui = rapid.ui(_$s);

            if(!(__r_ui instanceof rapid.ui.CheckBase)) {
              __r_ui.reset();
            }

          } else if(_$s.hasClass("date-picker")) {
            _$s.val("").data("datepicker").setDate("");

          } else if(_$s.hasClass("datetime-picker")) {
            _$s.val("").data("datetimepicker").update();

          } else if(this.tagName.toLowerCase() === "input" && this.type.toLowerCase() === "hidden") {
            _$s.val("");
          }
        });

      } else {
        var _value, _name;

        _$inputs.each(function() {
          _$s = rapid(this);
          _name = _$s.attr("name");

          if(rapid.isEmpty(_name)) {
            return true;
          }

          _value = rapid.json.get(data, _name);

          if(rapid.isDefined(_value)) {
            _value = rapid.nvl(_value, defaultValue);

            if(_$s.hasClass("r-value")) {

              __r_ui = rapid.ui(_$s);

              if(!(__r_ui instanceof rapid.ui.Picker)) {
                if(!(__r_ui instanceof rapid.ui.CheckBase) ||
                   (__r_ui instanceof rapid.ui.CheckBox && __r_ui.toggleValue())) {
                  __r_ui.val(_value);
                }
              }

            } else if(_$s.is(":checkbox") || _$s.is(":radio")) {
              _$s.filter("[value='" + _value + "']").prop("checked", true);

            } else if(_$s.hasClass("date-picker")) {
              if(rapid.hasValue(_value)) {
                _value = _value.r_removeTime();
              }
              _$s.val(_value).data("datepicker").setDate(_value);

            } else if(_$s.hasClass("datetime-picker")) {
              _$s.val(_value).data("datetimepicker").update();

            } else {
              _$s.val(_value);
            }
          }
        });
      }

      return this;
    };
    //#endregion

    KIT.updateRes = function(key, value) {
      window.top.rapid.res[key] = value;
    };

    KIT.getRes = function(key, value) {
      return rapid.res[key] = window.top.rapid.res[key];
    };

    KIT.getGridHeight = function(sectionLength) {
      var __height = 0,
        __i;

      rapid(".fn-section", function(i) {
        __height += rapid(this).outerHeight(true);
      });

      if(arguments.length === 1 && rapid.isNumber(arguments[0])) {
        for(__i = 1; __i <= sectionLength; __i++) {
          __height += rapid("#section" + __i).outerHeight(true);
        }
      }

      return rapid(".r-body").height() - __height;
    };

    /**
     * 判断是当前登录用户否为超级管理员 (zhaohaibo)
     * @returns {boolean}
     */
    KIT.isAdmin = function() {
      return RES.SESSION_USER_ID === RES.ADMIN_ROLE_ID;
    };

    /**
     * 权限判断
     * @param url
     * @returns {*}
     */
    KIT.judgePermission = function(url) {
      var _auth = null;

      rapid.post({
        url: RES.URL_API + "/getModelOperatingAuthorization",
        data: "url=" + url,
        async: false,
        success: function(result) {
          if(!rapid.isEmpty(result)) {
            _auth = KIT.toJson(result, "CODE");
          }
        }
      });

      return _auth;
    };

    /**
     * bootstrapTable插件工具函数
     */
    KIT.btspTable = {
      /**
       * jQuery
       * 注册bootstrapTable行单选事件 (zhaohaibo)
       * @param selector
       * @param callback 当行被选中时触发，参数为row:当前行的记录对象;index:行索引，函数内部this对象为表格DOM对象
       */
      registerRowSingleSelectEvent: function(selector, callback) {
        $(selector).on("change.njdt_row_select", "thead > tr > th.bs-checkbox input:checkbox", function(e) {
                     $(selector).children("tbody").children("tr")[$(this).is(":checked") ? "addClass" : "removeClass"]("selected");
                   })
                   .on("click.njdt_row_select", "tbody > tr:not('.no-records-found')", function(e) {

                     var __$_s = $(this),
                       __$_table = $(selector),
                       __id = rapid.nvl(__$_s.data("uniqueid"));

                     if(rapid.isEmpty(__id)) {
                       //rapid.error("表格 " + _$table.attr("id") + " 没有指定“uniqueId”参数 或 指定的字段名称有误。");
                       return;
                     }

                     var __$_other_tr = __$_s.siblings(),
                       __do_callback = false;

                     if(!__$_s.hasClass("select")) {
                       __do_callback = true;
                       __$_s.addClass("selected");
                       __$_other_tr.removeClass("selected");

                     } else {
                       if(__$_other_tr.hasClass("selected")) {
                         __do_callback = true;
                       }
                     }

                     var __row_index = __$_s.index();

                     if(__$_s.children("td.bs-checkbox").length === 1) {
                       __$_table.bootstrapTable("uncheckAll");
                       __$_table.bootstrapTable("check", __row_index);
                     }

                     if(__do_callback && rapid.isFunction(callback)) {
                       callback.call(__$_table[0], __$_table.bootstrapTable("getRowByUniqueId", __id), __row_index);
                     }

                   });
      },

      /**
       * jQuery
       * 合并单元格 (lijie)
       * @param options
       * @constructor
       */
      MergeCells: function(options) {
        var __id = options.id,
          __rows = options.rows,
          __fields = options.fields;

        if($("#" + __id) && __rows.length > 0 && __fields.length > 0) {
          var __indexs = [],
            __values = [],
            __len1 = __fields.length,
            __len2 = __rows.length,
            __i;

          for(__i = 0; __i < __len1; __i++) {
            __indexs.push(0);
            __values.push(undefined);
          }

          var __j, __item, __field, __field_value, __index;

          for(__i = 0; __i < __len2; __i++) {
            __item = __rows[__i];

            for(__j = 0; __j < __len1; __j++) {
              __field = __fields[__j];
              __field_value = __item[__field];
              __index = __indexs[__j];

              if(__i === 0) {
                __values[__j] = __field_value;
              }

              if(__values[__j] != __field_value) {
                $("#" + __id).bootstrapTable('mergeCells', {
                  index: __index, field: __field, rowspan: __i - __index
                });

                __values[__j] = __field_value;
                __indexs[__j] = __i;
              } else {
                if(__i === __len2 - 1) {
                  $("#" + __id).bootstrapTable('mergeCells', {
                    index: __index, field: __field, rowspan: __i - __index + 1
                  });
                }
              }
            }
          }
        }
      }
    };

    KIT.getEncryptParams = function(params){

      //params遍历，如果属性为空，则不传
      //params = filterParams(params)
      var timestamp = Math.round(new Date().getTime()).toString();
      params = Object.assign({}, params, { sn: timestamp, appId: rapid.appId})

      var signStr = sign(params, rapid.appSecret);
      var result = params = Object.assign({}, params, { _sign: signStr, appId: rapid.appId })
      var formData = new FormData();
      for (var key in result) {
        formData.append(key, result[key])
      }
      return result;
    };

    var filterParams = function(obj){

      var _newPar = {};
      for (var key in obj) {
        if ((obj[key] === 0 || obj[key]) && obj[key].toString().replace(/(^\s*)|(\s*$)/g, '') !== '') {
          _newPar[key] = obj[key];
        }
      }
      return _newPar;
    };

    var sign = function(data, skey){

      var signData = ksort(data);
      if (typeof data.sign != "undefined" && data.sign !== null) {
        delete signData.sign;
      }

      console.log("代签名:" + signData + '&' + skey);

      var signs = CryptoJS.MD5(signData + '&' + skey)
        .toString()
        .toUpperCase();

      return signs;
    };

    var ksort = function(params){

      var paramStr = "";
      if (typeof params == "string") {
        paramStr = params;
      }
      else if (typeof params == "object") {
        var arr = [];
        for (var i in params) {
          if (params.hasOwnProperty(i)) {
            arr.push((i + "=" + params[i]));
          }
        }
        paramStr = arr.join(("&"));
      }
      if (paramStr) {
        var newParamStr = paramStr.split("&").sort().join("&");
      }
      return newParamStr;
    };

    /**
     * 跳转菜单
     * @param href
     */
    KIT.openPage = function(href) {

      var __top_rapid = window.top.rapid;
      var __menu = __top_rapid("#side-menu").find("[href='" + href + "']");

        if(__menu.length === 0) {
        return false;
      }

      var __exists = __top_rapid('.J_menuTabs .page-tabs-content').find("[data-id='"+href+"']");
      if(__exists.length === 1) {
          window.top.$(__exists[0]).trigger("click");

          // __exists.trigger("click");
          return true;
      }

      var __index = __menu.data("index"),
        __name = __menu.children().text();

      var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + href + '">' + __name + ' <i class="fa fa-times-circle"></i></a>';
      __top_rapid('.J_menuTab').removeClass('active');

      // 添加选项卡对应的iframe
      var str1 = '<iframe class="J_iframe" name="iframe' + __index + '" width="100%" height="100%" src="' + href +
                 '" frameborder="0" data-id="' + href + '" seamless></iframe>';
      __top_rapid('.J_mainContent').find('iframe.J_iframe').css("display", "none").parents('.J_mainContent').append(str1);
      __top_rapid('.J_menuTabs .page-tabs-content').append(str);

      return true;
    };

      /**
       * 跳转菜单带参数
       * @param href
       */
      KIT.openPageCs = function(href) {
          var hrefs=href;
          var href=href.substring(0,href.indexOf('?'));

          var __top_rapid = window.top.rapid;
          var __menu = __top_rapid("#side-menu").find("[href='" + href + "']");

          if(__menu.length === 0) {
              return false;
          }

          __top_rapid('.J_mainContent').find('iframe.J_iframe').css("display", "none").parents('.J_mainContent').find("[data-id='"+href+"']").remove();
          __top_rapid('.J_menuTabs .page-tabs-content').find("[data-id='"+href+"']").remove();

          var __exists = __top_rapid('.J_menuTabs .page-tabs-content').find("[data-id='"+href+"']");
          if(__exists.length === 1) {


              window.top.$(__exists[0]).trigger("click");

              // __exists.trigger("click");
              return true;
          }

          var __index = __menu.data("index"),
              __name = __menu.children().text();

          var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + href + '">' + __name + ' <i class="fa fa-times-circle"></i></a>';
          __top_rapid('.J_menuTab').removeClass('active');

          // 添加选项卡对应的iframe
          var str1 = '<iframe class="J_iframe" name="iframe' + __index + '" width="100%" height="100%" src="' + hrefs +
              '" frameborder="0" data-id="' + href + '" seamless></iframe>';
          __top_rapid('.J_mainContent').find('iframe.J_iframe').css("display", "none").parents('.J_mainContent').append(str1);
          __top_rapid('.J_menuTabs .page-tabs-content').append(str);

          return true;
      };


    /**
     * 跳转创建tab
     * @param href
     */
    KIT.openPageTab = function(href,name,index) {
      var hrefs=href;
      var href=href.substring(0,href.indexOf('?'));

      var __top_rapid = window.top.rapid;


     

      __top_rapid('.J_mainContent').find('iframe.J_iframe').css("display", "none").parents('.J_mainContent').find("[data-id='"+href+"']").remove();
      __top_rapid('.J_menuTabs .page-tabs-content').find("[data-id='"+href+"']").remove();

      var __exists = __top_rapid('.J_menuTabs .page-tabs-content').find("[data-id='"+href+"']");
      if(__exists.length === 1) {


        window.top.$(__exists[0]).trigger("click");

        // __exists.trigger("click");
        return true;
      }


      var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + href + '">' + name + ' <i class="fa fa-times-circle"></i></a>';
      __top_rapid('.J_menuTab').removeClass('active');

      // 添加选项卡对应的iframe
      var str1 = '<iframe class="J_iframe" name="iframe' + index + '" width="100%" height="100%" src="' + hrefs +
          '" frameborder="0" data-id="' + href + '" seamless></iframe>';
      __top_rapid('.J_mainContent').find('iframe.J_iframe').css("display", "none").parents('.J_mainContent').append(str1);
      __top_rapid('.J_menuTabs .page-tabs-content').append(str);

      return true;
    };

    /**
     * jQuery
     * 初始化万能导入面板 (menglingbin)
     * @param option
     * @returns {boolean}
     */
    KIT.initPowerfulImportPanel = function(option) {
      //万能导入公共面板
      var _this = {};
      _this._o = {};
      _this._d = {};
      _this._p = {};

      var _option = {
        showTable: true,
        title: "万能导入",
        tableName: "",
        onUploadSuccess: $.noop
      };

      _this._o = $.extend(true, {}, _option, option);

      _this._p.windowid = "wndPowerfulImport";
      _this._p.fromid = "frmPowerfulImport";
      _this._p.uploadid = "powImportUploader";

      $("#" + _this._p.fromid).empty();

      var _outHTML = [];

      if(_this._o.showTable) {

        _outHTML.push("<div class='row'> <div class='g-group col-sm-12' id='partyNames_PowerfulImport'>");
        _outHTML.push("</div></div>");
        _outHTML.push("<div class='row'> <div class='g-group col-sm-12' id='udmKeys_PowerfulImport'>");
        _outHTML.push("<label>选择主键</label>");
        _outHTML.push("<select class='g-control'   name='udmKeyName'>");
        _outHTML.push("<option value=''>请选择</option>");
        _outHTML.push("</select>");
        _outHTML.push("</div></div>");
        _outHTML.push("<div class='row'> <div class='g-group col-sm-12' id='rulrs_PowerfulImport'>");

        _outHTML.push("</div></div>");

        $("#frmPowerfulImport").append(_outHTML.join(""));

        rapid.get({
          url: RES.URL_API + "/getPartyNameList",
          success: function(result) {
            if(rapid.isEmpty(result)) {
              return false;
            }

            var _combochtml = [];
            _combochtml.push("<label>模型表</label>");
            _combochtml.push("<select class='g-control' id='cbxpartyName_PowerfulImport'  name='partyName'>");
            _combochtml.push("<option value=''>请选择</option>");

            for(var i = 0; i < result.length; i++) {
              _combochtml.push("<option value='" + result[i].NAME + "' >" + result[i].NAMEGROUP + "</option>");
            }

            _combochtml.push("</select>");

            $("#partyNames_PowerfulImport").append(_combochtml.join(""));

            $("#cbxpartyName_PowerfulImport").on("change", function() {
              var _val = $(this).val();
              if(!rapid.isEmpty(_val)) {
                rapid.get({
                  url: RES.URL_API + "/getDataModelUDMKeyListByParty",
                  data: "partyName=" + _val,
                  success: function(result) {
                    var _combochtml1 = [];

                    if(rapid.isEmpty(result)) {
                      _combochtml1.push("<label>选择主键</label>");
                      _combochtml1.push("<select class='g-control'   name='udmKeyName'>");
                      _combochtml1.push("<option value=''>请选择</option>");
                      _combochtml1.push("</select>");
                      $("#udmKeys_PowerfulImport").empty();
                      $("#udmKeys_PowerfulImport").append(_combochtml1.join(""));
                    } else {
                      _combochtml1.push("<label>选择主键</label>");
                      _combochtml1.push("<select class='g-control'   name='udmKeyName'>");

                      for(var i = 0; i < result.length; i++) {
                        _combochtml1.push("<option value='" + result[i].VALUE + "' >" + result[i].TEXT + "</option>");
                      }

                      _combochtml1.push("</select>");
                      $("#udmKeys_PowerfulImport").empty();
                      $("#udmKeys_PowerfulImport").append(_combochtml1.join(""));
                    }
                  }
                });
              } else {
                var _combochtml3 = [];
                _combochtml3.push("<label>选择主键</label>");
                _combochtml3.push("<select class='g-control'   name='udmKeyName'>");
                _combochtml3.push("<option value=''>请选择</option>");
                _combochtml3.push("</select>");
                $("#udmKeys_PowerfulImport").empty();
                $("#udmKeys_PowerfulImport").append(_combochtml3.join(""));
              }
            });

          }
        });

        rapid.get({
          url: RES.URL_API + "/getCodeRulrList",
          success: function(result) {
            if(rapid.isEmpty(result)) {
              return false;
            }
            var _combochtml = [];
            _combochtml.push("<label>更新规则</label>");
            _combochtml.push("<select class='g-control'  name='rule'>");
            for(var i = 0; i < result.length; i++) {
              _combochtml.push("<option value='" + result[i].CUSTOMID + "' >" + result[i].CODENAME + "</option>");
            }
            _combochtml.push("</select>");
            $("#rulrs_PowerfulImport").append(_combochtml.join(""));
          }
        });

      } else {

        if(rapid.isEmpty(_this._o.tableName)) {
          rapid.warning("设定导入模型表名不能为空。");
          return false;
        }

        _outHTML.push("<input type='hidden' id='hidPartyName_PowerfulImport' name='partyName' >");
        _outHTML.push("<div class='row'> <div class='g-group col-sm-12' id='udmKeys_PowerfulImport'>");
        _outHTML.push("</div></div>");
        _outHTML.push("<div class='row'> <div class='g-group col-sm-12' id='rulrs_PowerfulImport'>");
        _outHTML.push("</div></div>");

        $("#frmPowerfulImport").append(_outHTML.join(""));

        $("#hidPartyName_PowerfulImport").val(_this._o.tableName);

        rapid.get({
          url: RES.URL_API + "/getDataModelUDMKeyListByParty",
          data: "partyName=" + _this._o.tableName,
          success: function(result) {
            if(rapid.isEmpty(result)) {
              return false;
            }

            var _combochtml = [];
            _combochtml.push("<label>选择主键</label>");
            _combochtml.push("<select class='g-control' name='udmKeyName'>");
            for(var i = 0; i < result.length; i++) {
              _combochtml.push("<option value='" + result[i].VALUE + "' >" + result[i].TEXT + "</option>");
            }
            _combochtml.push("</select>");
            $("#udmKeys_PowerfulImport").empty();
            $("#udmKeys_PowerfulImport").append(_combochtml.join(""));
          }
        });

        rapid.get({
          url: RES.URL_API + "/getCodeRulrList",
          success: function(result) {
            if(rapid.isEmpty(result)) {
              return false;
            }
            var _combochtml = [];
            _combochtml.push("<label>更新规则</label>");
            _combochtml.push("<select class='g-control'  name='rule'>");
            for(var i = 0; i < result.length; i++) {
              _combochtml.push("<option value='" + result[i].CUSTOMID + "' >" + result[i].CODENAME + "</option>");
            }
            _combochtml.push("</select>");
            $("#rulrs_PowerfulImport").append(_combochtml.join(""));
          }
        });
      }

      _this._d.window = rapid("#" + _this._p.windowid).window({
        title: _this._o.title,
        onShow: function() {
          /* $("#" + _this._p.uploadid).g_webuploader().reset();
           $("#" + _this._p.uploadid).g_webuploader().clearHtml();*/
        },
        onHide: function() {
          KIT.fillForm("#frmPowerfulImport", null, function() {
            if(this.name !== "partyName") {
              return this;
            }
          });
          $("#" + _this._p.uploadid).g_webuploader().reset();
          $("#thelist").empty();
        }
      });

      $("#" + _this._p.windowid).data("m_control", _this);

      $("#" + _this._p.uploadid).g_webuploader({
        server: RES.URL_API + "/importExcel",
        multiple: false,
        onUploadBefore: function(uploader) {
          uploader.options.formData = $("#" + _this._p.fromid).r_serializeJson();
          return true;
        },
        onUploadSuccess: function(file, response) {

          if(!rapid.isEmpty(response.message)) {
            rapid.warning(response.message, _this._o.onUploadSuccess);
          } else {
            _this._o.onUploadSuccess();
          }

        }
      });
    };

    /**
     * jQuery
     * 打开万能导入面板（必须先调用util.initPowerfulImportPanel方法后才可使用）(menglingbin)
     * @param option
     */
    KIT.openPowerfulImportPanel = function(option) {

      //万能导入公共面板
      var _this = {};
      _this._o = {};
      _this._d = {};
      _this._p = {};

      var _option = {
        selectorTableName: ""
      };

      _this._o = $.extend(true, {}, _option, option);

      var $maincol = $("#wndPowerfulImport").data("m_control");

      if($maincol._o.showTable && !rapid.isEmpty(_this._o.selectorTableName)) {
        $("#cbxpartyName_PowerfulImport").val(_this._o.selectorTableName);
      }
      $("#cbxpartyName_PowerfulImport").change();
      $maincol._d.window.show();
    };

    KIT.createWebuploaderImg = function() {
      return E("div").addClass("r-img-wrap-w", "r-size", "g-uploader-img-wrap")
                     .append(E("div").addClass("r-bd", "r-p-sm", "r-bd-12-3", "g-goods-cover"))
                     .append(
                       ButtonBuilder.tostring({
                         icon: "fa-trash-alt",
                         cssClass: "g-uploader-img-remove"
                       })
                     );
    };
    KIT.initWebuploaderImg = function(imgUuploaderSelector, options) {
      var __$_uploaders = $(imgUuploaderSelector),
        __len = __$_uploaders.length,
        __id;

      options = rapid.nvl(options, {});
      //options.server = rapid.nvl(options.server, options.aliyun ? "uploadImageToAliyun" : "webUploader");
      var __uploader = [];

      __$_uploaders.each(function(i) {
        var __$_s = $(this);

        options = rapid.nvl(options, {});

        options.id = rapid.nvl(options.id, rapid.id("imgUploader"), function(v) {
          if(__len > 1) {
            return v + i;
          }

          return v;
        });

        __uploader.push(
          __$_s.g_webuploader(rapid.extend(true, {
            uploadType: "image",
            multiple: false,
            hideFileName: true,
            server: options.server
          }, options))
        );

        if(i > 0) {
          __$_s.r_hide();
        }

        $(__$_s.next()).on("click", function() {
          var __$_up = $(this.element).prev();

          if(rapid.isEmpty(__$_up.g_webuploader().getSrc())) {
            return;
          }

          rapid.confirm("确定要删除已上传的图片么？", function(e) {
            if(e) {
              __$_up.g_webuploader().clearHtml();
            }
            __$_up = null;
          });

        });

      });

      return __uploader.length === 1 ? __uploader[0] : __uploader;
    };
    KIT.tmplTextArea = function(opts) {
      return rapid.extend(true, {
        type: "template",
        init: function() {

          rapid(this.element).html("<textarea class='r-corner-all' name = " + opts.name + " wrap=\"hard\" style='height:100px;width: 100%;'  id=" + rapid.id("textarea", opts.name) + "></textarea>").children()[0];

          this.val(this.__o__.value);
        },
        handlers: {
          value: function(value) {

            if(arguments.length === 0) {
              return rapid(this.element).children().val();
            }

            rapid(this.element).children().val(arguments[0]);
            return this;
          },
          disabled: function(value) {
            if(arguments.length === 0) {
              return this.__o__.disabled;
            }

            rapid(this.element).children().$textElem.attr('contenteditable', !value);
            return this;
          }
        }
      }, opts);
    };
    // wangEditor自定义控件参数
    KIT.tmplWangEditor = function(opts) {
      return rapid.extend(true, {
        type: "template",
        init: function() {
          var __wang_editor = new window.wangEditor(
            rapid(this.element).html(E.div().attr("id", rapid.id("wangeditor", this.name))).children()[0]
          );

          __wang_editor.customConfig.uploadImgServer = RES.URL_ROOT + "/api/upload";
          __wang_editor.create();
          this.tag("wangEditor", __wang_editor);

          var __o = this.__o__;
          this.value(rapid.nvl(__o.defaultValue, rapid.nvl(__o.value)));
        },
        handlers: {
          value: function(value) {
            if(arguments.length === 0) {
              return this.tag("wangEditor").txt.html();
            }

            this.tag("wangEditor").txt.html(value);
            return this;
          },
          disabled: function(value) {
            if(arguments.length === 0) {
              return this.__o__.disabled;
            }

            this.tag("wangEditor").$textElem.attr('contenteditable', !value);
            return this;
          }
        }
      }, opts);
    };

    KIT.tmpWebuploader = function(opts) {
      return rapid.extend(true, {
        type: "template",
        init: function() {
          this.tag("uploader", KIT.initWebuploaderImg(rapid(this.element).html("<div></div>").children(), opts));
        },
        handlers: {
          text: function(value) {
            if(arguments.length === 0) {
              return this.__o__.text;
            } else {
              rapid.ui.Template.base.text.apply(this, arguments);
            }

            return this;
          },
          value: function(value) {
            if(arguments.length === 0) {
              return this.tag("uploader").getSrc();
            }

            this.tag("uploader").fillSrc(value);
            if(this.tag("uploader")._o.uploadType == "file") {
              rapid(this.element).children().find("img").hide();
            }
            return this;
          },
          readonly: function(value) {
            if(arguments.length === 0) {
              return this.__o__.disabled;
            }

            rapid.ui.Template.base.readonly.apply(this, arguments);
            if(value) {
              rapid(this.element).children().find(".upload-btns").hide();
            } else {
              rapid(this.element).children().find(".upload-btns").show();
            }

            if(this.tag("uploader")._o.uploadType == "file") {
              rapid(this.element).children().find("img").hide();
              if(value) {
                var __text = this.__o__.text,
                  __R_text = rapid(this.__d_viewWrap).children();

                if(rapid.hasValue(__text)) {
                  var __index = __text.lastIndexOf("/");

                  if(__index > 0) {
                    __text = __text.substring(__index + 1);
                  }
                } else {
                  __text = "";
                }
                __R_text.html(__text);
              }
            }
            return this;
          },
          disabled: function(value) {
            if(arguments.length === 0) {
              return this.__o__.disabled;
            }

            this.__o__.disabled = value;
            if(value) {
              rapid(this.element).children().find(".upload-btns").hide();
            } else {
              rapid(this.element).children().find(".upload-btns").show();
            }
            return this;
          }
        }
      }, opts);
    };
  })();
  //endregion

  //region ====================> 函数、控件封装（折叠段注明需要引用的其它库）

  //region --------------------> SelectorBox - jQuery (menglingbin)
  (function() {
    var UI_SelectorBox = function(element, option) {
      /// <summary>
      /// SelectorBox
      /// </summary>
      /// <param name="element">主体控件的DOM对象</param>
      /// <param name="option">参数</param>
      this._o = {};
      this._d = {};
      this._p = {};

      var _option = {
        name: "",
        onclick: function() {
        }
      };

      var _this = this;
      var _$maincrl = $(element).data("m_control", _this);  //当前主控件对象，textbox

      _this._o = $.extend(true, {}, _option, option);
      _this._o.id = $(element).attr("id");
      _this._d.element = element;  //主控件DOM对象

      $(element).val("请点击选择...");

      var _hidHtml = "<input type='hidden' id='{0}' name='{1}' value='{2}' />";
      _hidHtml = _hidHtml.replace("{0}", _this._o.id + "_Mctolhid").replace("{1}", _this._o.name);

      if(!rapid.isUndefined(_this._o.value)) {
        _hidHtml = _hidHtml.replace("{2}", _this._o.value);
      } else {
        _hidHtml = _hidHtml.replace("{2}", "");
      }

      if(!rapid.isUndefined(_this._o.text)) {
        $(element).val(_this._o.text);
      }

      $(element).after(_hidHtml);

      var _$hidcrl = $(element).next();  //隐藏域DOM对象
      _this._d.hidelement = _$hidcrl[0];  //隐藏域JQ对象

      //初始化控件
      _$maincrl.prop("readonly", true);
      if(rapid.isEmpty(_$maincrl.val())) {
        _$maincrl.val("请点击选择...");
      }
      _$maincrl.css({
        "background-color": "#eaeaea",
        "cursor": "pointer"
      });

      //控件绑定onclick事件
      _$maincrl.on("click", function() {
        if(rapid.isFunction(_this._o.onclick)) {
          _this._o.onclick.apply(this, [_this]);
        }
      });
    };

    $.extend(UI_SelectorBox.prototype, {
      val: function() {
        var _d = this._d;
        if(arguments.length > 0) {
          $(_d.hidelement).val(arguments[0]);
          var _text = $(_d.element).val();
          $(_d.element).val(rapid.isEmpty(arguments[0]) ? "请点击选择..." : _text);
          return this;
        } else {
          return $(_d.hidelement).val();
        }
      },
      text: function() {
        var _d = this._d;
        if(arguments.length > 0) {
          $(_d.element).val(arguments[0]);
          $(_d.element).attr("title", arguments[0]);
          return this;
        } else {
          return $(_d.element).val();
        }
      },
      backDefault: function() {
        var _d = this._d;
        $(_d.hidelement).val("");
        $(_d.element).val("请点击选择...");
      }
    });

    $.fn.selectorbox = function(option) {
      var _$elment = $(this);
      var ui_SelectorBox = _$elment.data("m_control");
      if(rapid.isUndefined(ui_SelectorBox)) {
        ui_SelectorBox = new UI_SelectorBox(_$elment[0], option);
      }
      return ui_SelectorBox;
    };
  })();
  //endregion

  //region --------------------> checkboxlist - jQuery (menglingbin)
  (function() {
    var UI_CheckBoxList = function(option) {
      this._o = {};
      this._d = {};
      this._p = {};

      /// <summary>
      /// 复选框HTML模板（选中状态）
      /// </summary>
      this._p.CheckBoxTemplateChecked = "<label style=\"white-space:nowrap;\"><input type=\"checkbox\"  id=\"{0}\" checked=\"checked\" name=\"{1}\" value=\"{2}\" /><span>{3}</span></label>";

      /// <summary>
      /// 复选框HTML模板（未选中状态）
      /// </summary>
      this._p.CheckBoxTemplateUnchecked = "<label style=\"white-space:nowrap;\"><input type=\"checkbox\" id=\"{0}\" name=\"{1}\" value=\"{2}\" /><span>{3}</span></label>";

      var _option = {
        id: "",
        name: "",
        valueField: "",
        textField: "",
        size: 5,
        checked: false,
        dataSource: {
          transport: {
            url: "",
            data: "",
            success: function() {
            }
          },
          bindData: null
        },
        onChange: function() {
        }
      };

      var _this = this;

      _this._o = $.extend(true, {}, _option, option);

      var _checkboxTemp = "";

      if(_this._o.checked) {
        _checkboxTemp = _this._p.CheckBoxTemplateChecked;
      } else {
        _checkboxTemp = _this._p.CheckBoxTemplateUnchecked;
      }

      //全选的那个复选框的Id
      var _chkedallid = _this._o.id + "_CheckAll";
      _this._o.checkAllId = _chkedallid;

      var _checkAllHtml = _checkboxTemp.replace('{0}', _chkedallid).replace('{3}', "全选");

      var _outputHtml = [];

      var function_HtmlFactory = function(dataResource, size) {
        var _returnHtml = [],
          _dataTemp, _length, i;

        if(_this._o.size == 0) {
          if(rapid.isJson(dataResource)) {
            _dataTemp = [];
            _dataTemp.push(dataResource);
            dataResource = _dataTemp;
          }
          _length = dataResource.length;
          _returnHtml.push(_checkAllHtml);
          for(i = 0; i < _length; i++) {
            _returnHtml.push(_checkboxTemp.replace('{1}', _this._o.name).replace('{2}', dataResource[i][_this._o.valueField]).replace('{3}', dataResource[i][_this._o.textField]));
          }
        } else {
          if(rapid.isJson(dataResource)) {
            _dataTemp = [];
            _dataTemp.push(dataResource);
            dataResource = _dataTemp;
          }

          _returnHtml.push("<table class='g-noborder g-checkboxlist' style='border-collapse:collapse;border:0;'>");
          _returnHtml.push("<tr>");
          _returnHtml.push("<td colspan='" + _this._o.size + "' style='text-align:left;'>");
          _returnHtml.push(_checkAllHtml);
          _returnHtml.push("</td>");
          _returnHtml.push("</tr>");
          _length = dataResource.length;
          var _counter = 0;
          for(i = 0; i < _length; i++) {
            _counter++;
            if(_counter == 1) {
              _returnHtml.push("<tr>");
            }
            _returnHtml.push("<td >");
            _returnHtml.push(_checkboxTemp.replace('{1}', _this._o.name).replace('{2}', dataResource[i][_this._o.valueField]).replace('{3}', dataResource[i][_this._o.textField]) + "&nbsp;");
            _returnHtml.push("</td>");
            if(_counter == size) {
              _returnHtml.push("</tr>");
              _counter = 0;
            }
          }

          //如果最后一行不是正好显示size的个数，需补齐后面"<td></td>"
          if(_counter != 0) {
            _length = _this._o.size - _counter;

            for(i = 0; i < _length; i++) {
              _returnHtml.push("<td></td>");
            }
            _returnHtml.push("</tr>");
          }
          _returnHtml.push("</table>");
        }

        return _returnHtml.join("");
      };

      var function_bindcheckAlllEvent = function() {
        var _checkAllId = "#" + _this._o.checkAllId;   //抱住复选框的容器ID
        var _panelId = "#" + _this._o.id;  //抱住复选框的容器ID
        $(_checkAllId).on("change", function() {
          var _check = $(this).prop("checked");
          if(_check) {
            $(_panelId).find("input:checkbox").prop("checked", true);
          } else {
            $(_panelId).find("input:checkbox").prop("checked", false);
          }
        });
      };

      if(rapid.isJson(_this._o.dataSource.bindData) || rapid.isArray(_this._o.dataSource.bindData)) {
        _outputHtml.push(function_HtmlFactory(_this._o.dataSource.bindData, _this._o.size));
        $("#" + _this._o.id).append(_outputHtml);
        function_bindcheckAlllEvent();
      } else {
        rapid.get({
          url: _this._o.dataSource.transport.url,
          data: _this._o.dataSource.transport.data,
          success: function(result) {
            if(!rapid.isEmpty(result)) {
              _outputHtml.push(function_HtmlFactory(result, _this._o.size));
              $("#" + _this._o.id).append(_outputHtml);
              function_bindcheckAlllEvent();
            }

            if(rapid.isFunction(_this._o.dataSource.transport.success)) {
              _this._o.dataSource.transport.success.apply(this, [_this, result]);
            }
          }
        });
      }
    };

    $.extend(UI_CheckBoxList.prototype, {
      setValue: function(data) {
        if(rapid.isEmpty(data)) {
          return;
        }
        var _this = this;
        var _tempData = [];
        if(!rapid.isArray(data)) {
          _tempData = data.split(',');
        } else {
          _tempData = data;
        }

        var _checkboxes = $("#" + _this._o.id).find("input[type = 'checkbox']");

        var _dataLength = _tempData.length;
        var _checkboxesLength = _checkboxes.length;

        for(var i = 0; i < _dataLength; i++) {
          for(var j = 0; j < _checkboxesLength; j++) {
            var _tempcheckbox = _checkboxes.eq(j);
            if(_tempData[i] == _tempcheckbox.val()) {
              _tempcheckbox.prop("checked", "true");
            }
          }
        }
      },
      getValue: function() {
        var _this = this;
        var _returnData = [];
        var _checkboxes = $("#" + _this._o.id).find("input[type = 'checkbox']");
        var _checkboxesLength = _checkboxes.length;
        for(var j = 0; j < _checkboxesLength; j++) {
          var _tempcheckbox = _checkboxes.eq(j);
          if(_tempcheckbox.prop("checked")) {
            _returnData.push(_tempcheckbox.val());
          }
        }
        return _returnData;
      },
      getText: function() {
        var _this = this;
        var _returnData = [];
        var _checkboxes = $("#" + _this._o.id).find("input[type = 'checkbox']");
        var _checkboxesLength = _checkboxes.length;
        for(var j = 0; j < _checkboxesLength; j++) {
          var _tempcheckbox = _checkboxes.eq(j);
          if(_tempcheckbox.prop("checked")) {
            _returnData.push(_tempcheckbox.next().html());
          }
        }
        return _returnData;

      },
      clear: function() {
        var _this = this;
        $("#" + _this._o.id).html("");
        $("#" + _this._o.id).removeData("m_control")
      },
      checkAll: function() {
        var _this = this;
        var _checkAllId = "#" + _this._o.checkAllId;   //抱住复选框的容器ID
        var _panelId = "#" + _this._o.id;  //抱住复选框的容器ID
        $(_panelId).find("input[type='checkbox']").prop("checked", true);
      },
      uncheckAll: function() {
        var _this = this;
        var _checkAllId = "#" + _this._o.checkAllId;   //抱住复选框的容器ID
        var _panelId = "#" + _this._o.id;  //抱住复选框的容器ID
        $(_panelId).find("input[type='checkbox']").prop("checked", false);
      }
    });

    $.fn.checkboxlist = function(option, callback) {
      if(!rapid.isJson(option)) {
        option = {id: ""};
      }
      option.id = $(this).attr("id");
      var _$elment = $("#" + option.id);
      var ui_checkboxlist = _$elment.data("m_control");
      if(rapid.isUndefined(ui_checkboxlist)) {
        ui_checkboxlist = new UI_CheckBoxList(option);
      } else {
        if(rapid.isJson(option)) {
          if(rapid.isJson(option["dataSource"])) {
            var _this = ui_checkboxlist;
            if(rapid.isJson(option.dataSource.bindData) || rapid.isArray(option.dataSource.bindData)) {
              $("#" + _this._o.id).empty();
              ui_checkboxlist = new UI_CheckBoxList(option);
            } else if(rapid.isJson(option.dataSource.transport)) {
              $("#" + _this._o.id).empty();
              ui_checkboxlist = new UI_CheckBoxList(option);
            }
          }
        }
      }
      return ui_checkboxlist;
    }
  })();
  //endregion

  //region --------------------> BootstrapTable 参数 及 封装 - jQuery (zhaohaibo)
  if($.fn.bootstrapTable) {
    (function() {
      $.extend($.fn.bootstrapTable.defaults, {
        sortOrder: "desc",
        buttonsClass: "",
        contentType: "application/x-www-form-urlencoded",
        pagination: true,
        sidePagination: "server",
        pageSize: 10,
        uniqueId: "conflict_id",
        pageList: [10, 25, 50, 100]
      });
      rapid.Object.create("Table", function(selector, options) {
        rapid.Table.base.apply(this, arguments);

        this.element = $(selector)[0];

        if(rapid.hasValue(options)) {
          if(options.keyField) {
            options.uniqueId = options.keyField;
            delete options.keyField;
          }

          if(rapid.isFunction(options.onSelectRow) || options.selectable === true) {
            var _callback = rapid.isFunction(options.onSelectRow) ? options.onSelectRow : rapid.noop;
            delete options.onSelectRow;
            delete options.selectable;

            KIT.btspTable.registerRowSingleSelectEvent($(this.element).bootstrapTable(options), _callback);

          } else {
            $(this.element).bootstrapTable(options);
          }
        }

      }, {
        load: function(queryParams) {
          var _queryParams;

          if(rapid.isUndefined(queryParams)) {
            _queryParams = function(params) {
              return params;
            };

          } else {
            if(rapid.isJson(queryParams)) {
              _queryParams = function(params) {
                return $.extend(true, params, queryParams);
              };

            } else {
              rapid._error("load方法参数必须是Json对象。");
              return this;
            }

            var _$element = $(this.element);
            _$element.bootstrapTable("getOptions").queryParams = _queryParams;

            if(_$element.bootstrapTable("getOptions").pageNumber == 1) {
              _$element.bootstrapTable("refresh", {query: $.extend({offset: 0}, queryParams)});

            } else {
              _$element.bootstrapTable("refreshOptions", {pageNumber: 1});
            }
          }

          return this;
        },
        reload: function(queryParams) {
          if(rapid.isDefined(queryParams)) {
            if(rapid.isFunction(queryParams)) {
              rapid._error("load方法参数必须是Json对象。");
              return this;
            }

            $(this.element).bootstrapTable("refresh", {query: queryParams});

          } else {
            $(this.element).bootstrapTable("refresh");
          }

          return this;
        },
        removeAll: function() {
          $(this.element).bootstrapTable("removeAll");
          return this;
        },
        item: function(key) {
          return $(this.element).bootstrapTable("getRowByUniqueId", key)
        },
        selections: function() {
          return $(this.element).bootstrapTable("getSelections");
        },
        settings: function(options) {
          $(this.element).bootstrapTable("refreshOptions", options);

          return this;
        }
      });

      rapid.fn.table = function(options) {
        if(rapid.hasValue(options)) {
          if(rapid.isJson(options)) {
            return rapid.Table(this.selector, options);

          } else if(rapid.isString(options)) {
            if(rapid.isFunction(rapid.Table.prototype[options])) {
              if(arguments.length === 2) {
                return rapid.Table(this.selector)[options](arguments[1]);

              } else {
                return rapid.Table(this.selector)[options]();
              }
            }
          }
        }

        return rapid.Table(this.selector);
      };
    })();
  }
  //endregion

  //region --------------------> jsTree 封装 - jQuery (menglingbin)
  if($.fn.jstree) {
    (function() {
      var UI_Tree = function(option) {
        this._o = {};
        this._d = {};
        this._p = {};

        var _pluginsAttr = {
          themes: "themes",
          json_data: "json_data",
          checkbox: "checkbox"
        };
        var _option = {
          plugins: [_pluginsAttr.themes, "tie_selection"],//, "json_data","checkbox"
          themes: {
            theme: "classic",
            dots: true,
            icons: false
          },
          core: {}
        };

        this._p.o = option;

        var _this = this;

        _this._o = $.extend(true, {}, _option);
        _this._o["id"] = option.id;

        var _$maincrl = $("#" + _this._o["id"]).data("m_control", _this);  //当前主控件对象
        _this._d.element = $("#" + _this._o["id"])[0];  //主控件DOM对象

        if(rapid.isJson(option)) {
          if(rapid.isDefined(option["checkbox"])) {
            if(option["checkbox"]) {
              _this._o.plugins.push(_pluginsAttr.checkbox);
              if(rapid.isFunction(option["onselected"])) {
                rapid.error("onselected事件只允许在不启用checkbox的情况下使用。");
                return false;
              }
            } else {
              if(rapid.isFunction(option["onchanged"])) {
                rapid.error("onchanged事件只允许在启用checkbox的情况下使用。");
                return false;
              }
            }
          } else {

            if(rapid.isFunction(option["onchanged"])) {
              rapid.error("onchanged事件只允许在启用checkbox的情况下使用。");
              return false;
            }

          }

          if(rapid.isDefined(option["databind"])) {
            _this._o.plugins.push(_pluginsAttr.json_data);
            if(rapid.isJson(option["databind"])) {
              $.extend(true, _this._o.core, {
                data: option["databind"]
              });
            }
          } else {
            $.extend(true, _this._o.core, {
              data: {
                url: option.data.url,
                data: option.data.data
              }
            });
          }
        } else {
          rapid.error("Tree控件缺少有效参数。");
          return false;
        }

        var $_jstree = $("#" + _this._o["id"]).jstree(
          _this._o
        );

        if(rapid.isFunction(option["onclick"])) {
          $_jstree.bind("click.jstree", function(event) {
            var eventNodeName = event.target.nodeName;
            if(eventNodeName == 'INS') {
              return;
            } else if(eventNodeName == 'A') {
              var $subject = $(event.target).parent();
              if($subject.find('ul').length > 0) {
              } else {
                //选择的id值
                //alert($(event.target).parents('li').attr('id'));
                option["onclick"].apply(_this, [event.target, $(event.target).parents('li').attr('id')]);
              }
            }
          });
        }

        if(rapid.isFunction(option["onloaded"])) {
          $_jstree.bind("loaded.jstree", function(event, data) {
            option["onloaded"].apply(_this, [event.target, data.instance]);
          });
        }

        if(rapid.isFunction(option["onchanged"])) {
          $_jstree.bind("changed.jstree", function(event, data) {
            //var $_lastnode = $("#"+_this._o["id"]).data("jstree_lastval");
            //var $_nownode = data.instance.get_node(data.selected[0]);
            //if(rapid.isEmpty($_lastnode) || $_lastnode.id != $_nownode.id){
            //$("#"+_this._o["id"]).data("jstree_lastval",$_nownode);
            var _topcheck = $("#" + _this._o["id"]).jstree().get_top_checked();
            var _bottomcheck = $("#" + _this._o["id"]).jstree().get_bottom_checked();

            option["onchanged"].apply(_this, [event.target, data.instance, data.selected, _topcheck, _bottomcheck]);
            // }
          });
        }

        if(rapid.isFunction(option["onselected"])) {
          $_jstree.bind("select_node.jstree", function(event, data) {
            var $_node = data.instance.get_node(data.selected[0]);
            option["onselected"].apply(_this, [event.target, data.instance, $_node]);
          });
        }

        _this._d.objtree = $("#" + _this._o["id"]).jstree();
      };

      $.extend(UI_Tree.prototype, {
        refresh: function(data) {
          /*        if(!rapid.isEmpty(data) && rapid.isJson(data)) {
           _this._o.core.data = data;
           return  $("#" + this._o["id"]).jstree(
           $.extend({}, _this._o)
           ).refresh();
           }else{
           return this._d.objtree.refresh();
           }*/

          return this._d.objtree.refresh(data);
        },
        getchecked: function() {
          var _checkedList = this._d.objtree.get_checked(true);

          if(rapid.isArray(_checkedList)) {
            var _ids = [];

            var _listLen = _checkedList.length;

            for(var i = 0; i < _listLen; i++) {

              var _notexist = true;

              for(j = 0; j < _ids.length; j++) {
                if(_checkedList[i]["id"] == _ids[j]) {
                  _notexist = false;
                  break;
                }
              }

              if(_notexist) {
                _ids.push(_checkedList[i]["id"]);
              }

              var _parents = _checkedList[i]["parents"];

              if(rapid.isArray(_parents)) {
                var _len = _parents.length;
                for(var k = 0; k < _len; k++) {
                  var _notexist1 = true;
                  if(_parents[k] == "#") {
                    continue;
                  } else {
                    for(j = 0; j < _ids.length; j++) {
                      if(_parents[k] == _ids[j]) {
                        _notexist1 = false;
                        break;
                      }
                    }
                    if(_notexist1) {
                      _ids.push(_parents[k]);
                    }
                  }
                }
              }
            }
            return _ids.join(",");
          } else {
            return "";
          }
          var _ids = [];
          $("#" + this._o.id + " .jstree-undetermined").each(function(index) {
            var _v = $(this).parent().parent().attr("id");
            _ids.push(_v);
          });

          var __ids = _ids.length > 0 ? "," + _ids.join(",") : "";

          return this._d.objtree.get_checked(true) + __ids;
        },
        getcheckedtext: function(isBottom) {
          var _textArr = [];
          var _thisObj = this._d.objtree;

          var _ids = "";
          if(isBottom) {
            _ids = _thisObj.get_bottom_checked();
          } else {
            _ids = _thisObj.get_checked();
          }

          if(!rapid.isEmpty(_ids)) {
            var _len = _ids.length;
            for(var i = 0; i < _len; i++) {
              _textArr.push(_thisObj.get_text(_ids[i]));
            }
            return _textArr;
          }

          return "";
        },
        getbottomchecked: function() {
          return this._d.objtree.get_bottom_checked(null);
        },
        gettopchecked: function() {
          return this._d.objtree.get_top_checked(null);
        },
        getselected: function() {
          return (this._d.objtree.get_selected(true))[0];
        },
        getparent: function(nodeid) {
          if(rapid.isEmpty(nodeid)) {
            return false;
          }
          return this._d.objtree.get_parent(nodeid);
        },
        getnode: function(nodeid) {
          if(rapid.isEmpty(nodeid)) {
            return false;
          }
          return this._d.objtree.get_node(nodeid);
        },
        selectall: function(trigger) {
          //true 不触发changed false触发changed
          this._d.objtree.select_all(trigger);
        },
        deselectall: function(trigger) {
          this._d.objtree.deselect_all(trigger);
        },
        checkall: function() {
          this._d.objtree.check_all();
        },
        uncheckall: function() {
          this._d.objtree.uncheck_all();
        },
        openall: function() {
          this._d.objtree.open_all();
        },
        opennode: function($node) {
          this._d.objtree.open_node($node);
        },
        closeall: function() {
          this._d.objtree.close_all();
        },
        ischecked: function(nodeid) {
          if(rapid.isEmpty(nodeid)) {
            return false;
          }
          return this._d.objtree.is_checked(nodeid);
        },
        gettext: function(nodeid) {
          if(rapid.isEmpty(nodeid)) {
            return "";
          }
          return this._d.objtree.get_text(nodeid);
        },
        checknodes: function(nodeids, isbottom) {
          //不会展开节点  selectednopde会展开节点
          if(rapid.isEmpty(nodeids)) {
            return false;
          }
          var _this = this;
          var _ids = [];
          if(rapid.isArray(nodeids)) {
            _ids = nodeids;
          } else {
            _ids = nodeids.toString().split(',');
          }

          var _length = _ids.length;
          if(_length == 1) {
            _this._d.objtree.check_node(_ids[0]);
          } else {
            $.each(_ids, function(i, n) {
              _this._d.objtree.check_node(n.toString());
            });
          }

          var _isbottom = false;

          if(!rapid.isEmpty(isbottom)) {
            _isbottom = isbottom;
          }

          if(!_isbottom) {
            var _checkidsstr = this._d.objtree.get_checked();

            var _uncheckIds = [];

            if(!rapid.isEmpty(_checkidsstr)) {

              $.each(_checkidsstr, function(i, n) {

                var _counter = 0;

                $.each(_ids, function(k, s) {
                  if(n.toString() == s.toString()) {
                    _counter++;
                  }
                });

                if(_counter == 0) {
                  _uncheckIds.push(n.toString());
                }
              });
              $.each(_uncheckIds, function(i, n) {
                _this._d.objtree.uncheck_node(n.toString());
              });
            }
          }

        },
        unchecknode: function(nodeids) {
          if(rapid.isEmpty(nodeids)) {
            return false;
          }
          var _this = this;
          var _ids = [];
          if(rapid.isArray(nodeids)) {
            _ids = nodeids;
          } else {
            _ids = nodeids.toString().split(',');
          }
          var _length = _ids.length;
          if(_length == 1) {
            _this._d.objtree.uncheck_node(_ids[0]);
          } else {
            $.each(_ids, function(i, n) {
              _this._d.objtree.uncheck_node(n.toString());
            });
          }
        },
        selectnodes: function(nodeids) {
          //不会展开节点  selectednopde会展开节点
          if(rapid.isEmpty(nodeids)) {
            return false;
          }
          var _this = this;
          var _ids = [];
          if(rapid.isArray(nodeids)) {
            _ids = nodeids;
          } else {
            _ids = nodeids.toString().split(',');
          }
          var _length = _ids.length;
          if(_length == 1) {
            _this._d.objtree.select_node(_ids[0]);
          } else {
            $.each(_ids, function(i, n) {
              _this._d.objtree.select_node(n.toString());
            });
          }
        },
        deselectnode: function(nodeids) {
          if(rapid.isEmpty(nodeids)) {
            return false;
          }
          var _this = this;
          var _ids = [];
          if(rapid.isArray(nodeids)) {
            _ids = nodeids;
          } else {
            _ids = nodeids.toString().split(',');
          }
          var _length = _ids.length;
          if(_length == 1) {
            _this._d.objtree.deselect_node(_ids[0]);
          } else {
            $.each(_ids, function(i, n) {
              _this._d.objtree.deselect_node(n.toString());
            });
          }
        }
      });

      $.fn.g_jstree = function(option) {
        if(!rapid.isJson(option)) {
          option = {id: ""};
        }
        option.id = $(this).attr("id");
        var _$elment = $("#" + option.id);
        var ui_tree = _$elment.data("m_control");

        if(option["data"] && !rapid.isUndefined(ui_tree)) {
          ui_tree._p.o.data = option.data;
          if(option["onloaded"]) {
            ui_tree._p.o.onloaded = option.onloaded;
          }
          ui_tree._d.objtree.destroy();
          ui_tree = new UI_Tree(ui_tree._p.o);
        }

        if(rapid.isUndefined(ui_tree)) {
          ui_tree = new UI_Tree(option);
        }
        return ui_tree;
      };
    })();
  }

  //endregion

  //region --------------------> webuploader 封装 - jQuery (menglingbin)
  (function() {

    var UI_WebUploader = function(option) {

      this._o = {};
      this._d = {};
      this._p = {
        filePath: [],
        clearHtml: function(obj) {
          $("#" + obj._p.filelistid).html("");
          obj._d.uploader.reset();

        },
        clearQueue: function() {
          if(arguments.length > 1) {
            var file = arguments[1];
            arguments[0]._d.uploader.removeFile(file);
          } else if(arguments.length == 1) {
            var files = this._d.uploader.getFiles();
            for(var i = 0; i < files.length; i++) {
              arguments[0]._d.uploader.removeFile(files[i]);
            }
          }
        },
        fillSrc: function(obj, src) {
          var img = '<div id="WU_FILE_1" class="file-item thumbnail" style="width: 100%; height: 100%; line-height: ' + (obj._p.thumbnailWidth * obj._o.ratio - 14) + 'px; text-align: center;">' +
                    '<img style="width: auto; max-height: 100%; display: inline-block;" src="' + src + '">' +
                    '<input type="hidden" id="hidUploader' + obj._o.name + '" name="' + obj._o.name + '" value="' + src + '">' +
                    '</div>';

          $("#" + obj._p.filelistid).append(img);
        }
      };

      var _option = {
        id: "",
        uploadType: "file",  //file/image,
        multiple: true,
        name: "",
        hideFileName: false,
        ratio: 1,
        swf: '/lib/webuploader/Uploader.swf',
        pick: "",
        server: "",
        chunked: false,//是否要分片处理大文件上传
        threads: 1, //允许同时上传文件数
        fileNumLimit: 1,
        timeout: 0,
        hide: true, //蒙板
        onUploadBefore: function(obj) {
          return true;
        },
        onUploadSuccess: function(file, response) {

        },
        onUploadFinished: $.noop
      };

      var _this = this;

      _this._o = $.extend(true, {}, _option, option);

      //私有属性变量
      _this._p.filelistid = _this._o.id + "_filelist";
      _this._p.pickerid = _this._o.id + "_picker";
      _this._p.uploadbtnid = _this._o.id + "_uploadbtn";

      //region 根据上传类型设置特定属性和私有变量

      if(_this._o.uploadType == "file") {
        _this._p.state = "pending";
        _this._o.resize = false;
      } else {
        _this._p.ratio = window.devicePixelRatio || 1;
        _this._p.thumbnailWidth = 100 * _this._p.ratio;
        _this._p.thumbnailHeight = 100 * _this._p.ratio;
        _this._o.auto = true;
        _this._o.accept = {
          title: 'Images',
          extensions: 'gif,jpg,jpeg,bmp,png',
          mimeTypes: ['image/jpg,image/gif,image/jpeg,image/bmp,image/png']
        };

        if(!rapid.isUndefined(_this._o.extensions)) {
          _this._o.accept.extensions = _this._o.extensions;
          delete _this._o.extensions;
        }

      }

      //endregion

      _this._o.pick = "#" + _this._p.pickerid;

      var _$maincrl = $("#" + _this._o.id).data("m_control", _this);

      $("#" + _this._o.id).addClass("wu-example");

      //region 拼接界面展示HTML
      $("#" + _this._o.id).empty();
      var _outHtml = [];
      _outHtml.push("<div class='wu-example'>");
      var style = "";
      if(_this._o.uploadType == "image" && !_this._o.multiple) {
        style = " style='width: " + _this._p.thumbnailWidth * _this._o.ratio + "px; height: " + _this._p.thumbnailHeight * _this._o.ratio + "px; border: 1px solid #e5e6e7; margin-bottom: 5px;' ";
      }
      _outHtml.push("<div id='" + _this._p.filelistid + "' class='uploader-list' " + style + "></div>");
      _outHtml.push("<div class='upload-btns r-clearfix'>");

      if(_this._o.uploadType == "image" && !_this._o.multiple) {
        style = " margin-left: " + (_this._p.thumbnailWidth * _this._o.ratio - 78) / 2 + "px; ";
      }
      _outHtml.push(" <div id='" + _this._p.pickerid + "' style='float:left; " + style + "'>选择文件</div>");
      if(_this._o.uploadType == "file") {
        _outHtml.push("<div style='float:left'><button id='" + _this._p.uploadbtnid + "' class='startUpload startUpload-btn startUpload-btn-default'>开始上传</button></div>");
      }
      _outHtml.push("</div></div>");
      $("#" + _this._o.id).append(_outHtml.join(""));
      //endregion

      if(_this._o.uploadType == "file") {
        //region 文件上传

        _this._d.uploader = WebUploader.create(_this._o);

        // 当有文件添加进来的时候
        _this._d.uploader.on('fileQueued', function(file) {
          $("#" + _this._p.filelistid).append('<div id="' + _this._o.id + file.id + '" class="item">' +
                                              '<h4 class="info">' + file.name + '</h4>' +
                                              '<p class="state">等待上传...</p>' +
                                              '</div>');
        });

        // 文件上传过程中创建进度条实时显示。
        _this._d.uploader.on('uploadProgress', function(file, percentage) {
          var $li = $('#' + _this._o.id + file.id),
            $percent = $li.find('.progress .progress-bar');

          // 避免重复创建
          if(!$percent.length) {
            $percent = $('<div class="progress progress-striped active">' +
                         '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                         '</div>' +
                         '</div>').appendTo($li).find('.progress-bar');
          }

          $li.find('p.state').text('上传中');

          $percent.css('width', percentage * 100 + '%');
        });

        _this._d.uploader.on('uploadSuccess', function(file, response) {
          if(rapid.isString(response._raw)) {
          }
          var _json = eval("(" + response._raw + ")");
          if(rapid.isFunction(_this._o.onUploadSuccess)) {
            _this._o.onUploadSuccess.apply(this, [file, _json]);
          }
          _this._p.clearQueue(_this, file);

          if(_json.state == "1") {
            $('#' + _this._o.id + file.id).find('p.state').html('已上传');

            if(_this._o.multiple) {
              _this._p.filePath.push(_json.data);
            } else {
              _this._p.filePath = [_json.data];
            }

          } else {
            $('#' + _this._o.id + file.id).find('p.state').html('上传出错');
          }

          //$('#' + file.id).find('p.state').next().fadeOut('slow',function(){});
        });

        _this._d.uploader.on('uploadError', function(file) {
          _this._p.clearQueue(_this, file);
          $('#' + _this._o.id + file.id).find('p.state').html('上传出错');
        });

        _this._d.uploader.on('uploadComplete', function(file) {
          $('#' + _this._o.id + file.id).find('.progress').fadeOut();
        });

        _this._d.uploader.on('uploadFinished', function() {
          if(rapid.isFunction(_this._o.onUploadFinished)) {
            var files = _this._d.uploader.getFiles();

            _this._o.onUploadFinished.apply(this, files);
          }
        });

        _this._d.uploader.on('all', function(type) {
          if(type === 'startUpload') {
            _this._p.state = 'uploading';
          } else if(type === 'stopUpload') {
            _this._p.state = 'paused';
          } else if(type === 'uploadFinished') {
            _this._p.state = 'done';
          }

          if(_this._p.state === 'uploading') {
            $("#" + _this._p.uploadbtnid).text('暂停上传');
          } else {
            $("#" + _this._p.uploadbtnid).text('开始上传');
          }
        });

        $("#" + _this._p.uploadbtnid).on('click', function() {
          if(_this._p.state === 'uploading') {
            _this._d.uploader.stop();
          } else {
            _this._d.uploader.stop();
            if(rapid.isFunction(_this._o.onUploadBefore)) {
              var _valid = _this._o.onUploadBefore.apply(this, [_this._d.uploader]);
              if(_valid) {
                _this._d.uploader.upload();
              } else {

                return false;
              }
            } else {
              _this._d.uploader.upload();
            }
          }
        });
        //endregion
      } else {
        //region 纯图片上传 选择图片就自动上传
        // 初始化Web Uploader
        _this._d.uploader = WebUploader.create(_this._o);

        // 当有文件添加进来的时候
        _this._d.uploader.on('fileQueued', function(file) {
          var __msg = _this._d.waitMsg;

          if(rapid.isEmpty(__msg)) {
            __msg = _this._d.waitMsg = rapid.wait();
          }

          var arr = [];
          var lis = $(this).data("lis");
          if(!rapid.isEmpty(lis)) {
            arr = lis;
          }
          var $li = $(
            '<div id="' + _this._o.id + file.id + '" class="file-item thumbnail" style="width: 100%; height: 100%; line-height: ' + (_this._p.thumbnailWidth * _this._o.ratio - 14) + 'px; text-align: center;">' +
            '<img style="width: auto; max-height: 100%; display: inline-block;">' +
            (rapid.isEmpty(_this._o.name) ? "" : "<input type='hidden' name='" + _this._o.name + "' />") +
            (!_this._o.hideFileName ? '<div class="info">' + file.name + '</div>' : "") +
            '</div>'
          );
          //$img = $li.find('img');

          arr.push($li);
          $(this).data("lis", arr);
          //$("#" + _this._p.filelistid).append($li);

          // 创建缩略图
          // _this._d.uploader.makeThumb(file, function(error, src) {
          //   if(error) {
          //     $img.replaceWith('<span>不能预览</span>');
          //     return;
          //   }
          //
          //   $img.attr('src', src);
          // }, _this._p.thumbnailWidth, _this._p.thumbnailHeight);
        });

        _this._d.uploader.on('filesQueued', function(files) {
          var __msg = _this._d.waitMsg;

          if(rapid.isEmpty(__msg)) {
            __msg = _this._d.waitMsg = rapid.wait();
          }
          if(files.length > _this._o.fileNumLimit) {
            if(!rapid.isEmpty(__msg)) {
              __msg.hide();
              _this._d.waitMsg = null;
            }
            rapid.error("选择图片数超过限定数：" + _this._o.fileNumLimit + "！");
            $(this).removeData("lis");
            return false;
          }

          var flag = true;
          for(var i = 0; i < files.length; i++) {
            if(_this._o.accept.extensions.indexOf(files[0].name.substr(files[0].name.lastIndexOf(".") + 1)) < 0) {
              if(!rapid.isEmpty(__msg)) {
                __msg.hide();
                _this._d.waitMsg = null;
              }
              rapid.error("选择的文件包含了非图片文件！");
              $(this).removeData("lis");
              flag = false;
              break;
            }
          }

          if(flag) {
            if(!_this._o.multiple) {
              if(_this._o.auto) {
                $("#" + _this._p.filelistid).html("");
              } else {
                _this._p.clearHtml(_this);
              }
            }

            var lis = $(this).data("lis");

            if(!rapid.isEmpty(lis)) {
              for(var i = 0; i < lis.length; i++) {
                var $li = $(lis[i]);
                $("#" + _this._p.filelistid).append($li);
                var $img = $li.find("img");
                var file = files[i];

                // 创建缩略图
                _this._d.uploader.makeThumb(files[i], function(error, src) {
                  if(error) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                  }

                  $img.attr('src', src);
                }, _this._p.thumbnailWidth, _this._p.thumbnailHeight);
              }
            }

            $(this).removeData("lis");
          }
          if(!rapid.isEmpty(__msg)) {
            __msg.hide();
            _this._d.waitMsg = null;
          }
        });

        // 文件上传过程中创建进度条实时显示。
        _this._d.uploader.on('uploadProgress', function(file, percentage) {
          var $li = $('#' + _this._o.id + file.id),
            $percent = $li.find('.progress span');

          // 避免重复创建
          if(!$percent.length) {
            $percent = $('<p class="progress"><span></span></p>')
              .appendTo($li)
              .find('span');
          }

          $percent.css('width', percentage * 100 + '%');
        });

        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        _this._d.uploader.on('uploadSuccess', function(file, response) {
          if(rapid.isFunction(_this._o.onUploadSuccess)) {
            _this._o.onUploadSuccess.apply(this, [file, response]);
          }
          var img = $("#" + _this._o.id + file.id).find("img");
          if(rapid.isString(response)) {
            img.attr("src", response);
            img.next().val(response);

          } else {
            if(rapid.isDefined(response.data)) {
              if(rapid.isArray(response.data)) {
                img.attr("src", response.data[0]);
                img.next().val(response.data[0]);
              } else {
                img.attr("src", response.data);
                img.next().val(response.data);
              }

            } else {
              img.attr("src", response._raw);
              img.next().val(response._raw);
            }
          }
          _this._p.clearQueue(_this, file);
          $('#' + _this._o.id + file.id).addClass('upload-state-done');
        });

        // 文件上传失败，现实上传出错。
        _this._d.uploader.on('uploadError', function(file) {
          var $li = $('#' + _this._o.id + file.id),
            $error = $li.find('div.error');

          // 避免重复创建
          if(!$error.length) {
            $error = $('<div class="error"></div>').appendTo($li);
          }

          _this._p.clearQueue(_this, file);
          $error.text('上传失败');
          var __msg = _this._d.waitMsg;

          if(!rapid.isEmpty(__msg)) {
            __msg.hide();
            _this._d.waitMsg = null;
          }
        });

        // 完成上传完了，成功或者失败，先删除进度条。
        _this._d.uploader.on('uploadComplete', function(file) {
          $('#' + _this._o.id + file.id).find('.progress').remove();

          var __msg = _this._d.waitMsg;

          if(!rapid.isEmpty(__msg)) {
            __msg.hide();
            _this._d.waitMsg = null;
          }
        });

        //endregion
      }

      _this._d.uploader.on('error', function(type) {
        var errorMsg = "上传文件发生错误！";

        switch(type) {
          case "Q_EXCEED_NUM_LIMIT":
            errorMsg = "总文件数量超出限制";
            break;
          case "Q_EXCEED_SIZE_LIMIT":
            errorMsg = "总文件大小超出限制！";
            break;
          case "F_EXCEED_SIZE":
            errorMsg = "文件大小超出限制！";
            break;
          case "F_DUPLICATE":
            errorMsg = "文件已存在！";
            break;
          case "Q_TYPE_DENIED":
            errorMsg = "文件类型错误！";
            break;
          default:
            break
        }

        rapid.error(errorMsg);
        var __msg = _this._d.waitMsg;

        if(!rapid.isEmpty(__msg)) {
          __msg.hide();
          _this._d.waitMsg = null;
        }
      });
    };

    $.extend(UI_WebUploader.prototype, {
      getobject: function() {
        return this._d.uploader;
      },
      clearHtml: function() {
        this._p.filePath = [];
        this._p.clearHtml(this);
      },
      clearQueue: function() {
        this._p.filePath = [];
        this._p.clearQueue(this);
      },
      fillSrc: function(src) {
        if(rapid.isEmpty(src)) {
          return;
        }
        this._p.fillSrc(this, src);
      },
      getSrc: function() {
        if(this._o.uploadType === "image") {
          return rapid.nvl($("#" + this._o.id).find("img").attr("src"));
        } else {
          return rapid.nvl(this._p.filePath.join("|"));
        }
      },
      reset: function() {
        this._p.filePath = [];
        this._d.uploader.reset();
      }
    });

    $.fn.g_webuploader = function(option) {
      if(rapid.isUndefined(option)) {
        return $(this).data("m_control");
      }

      if(!rapid.isJson(option)) {
        option = {id: $(this).attr("id")};
      } else {
        option = jQuery.extend(true, {id: $(this).attr("id")}, option);
      }

      if(rapid.isUndefined($(this).attr("id"))) {
        $(this).attr("id", option.id);
      }

      // option.id = $(this).attr("id");
      // var _$elment = $("#" + option.id);
      // var ui_webuploader = _$elment.data("m_control");
      var ui_webuploader = $(this).data("m_control");
      if(rapid.isUndefined(ui_webuploader)) {
        ui_webuploader = new UI_WebUploader(option);
      }
      return ui_webuploader;
    }
  })();
  //endregion

  //region --------------------> ImgViewer Control - jQuery (lijie)
  (function() {
    KIT.ImgViewer = function(options) {
      var $this = this;

      $this.options = jQuery.extend(true, {
        id: "",
        height: "",
        separateline: {
          header: false,
          footer: false
        },
        read: { //读取 - 优先
          url: "",
          params: {},
          success: jQuery.noop
        },
        data: [], //静态数据 - 次要
        loop: true, //循环（未实现）
        autoplay: false //自动播放（未实现）
      }, options);

      if(rapid.isEmpty($this.options.id)) {
        rapid.error("未找到容器！");
        return false;
      }

      if(rapid.browser.mobile) {
        $this.click = "touchend";
      } else {
        $this.click = "click";
      }

      $this.container = $("#" + $this.options.id);

      //拼接dom
      $this._joinElementData = function() {
        var stringBuilder = [];

        stringBuilder.push("<div class='view-header'>");

        var height = "";
        if(!rapid.isEmpty($this.options.height) && !isNaN($this.options.height)) {
          height = "height: " + $this.options.height + "px";
        } else {
          if($this.options.height.indexOf("%") > 0) {
            var h = $this.options.height.substring(0, $this.options.height.indexOf("%"));
            if(!isNaN(h)) {
              height = "height: " + $this.options.height + ";";
            }
          } else {
            height = "height: 339px;";
          }
        }

        stringBuilder.push("<div class='view-original' style='" + height + "'>");
        stringBuilder.push("<img class='originalImage' src='' style='width: auto; height: 100%;'/>")
        stringBuilder.push("</div>");

        stringBuilder.push("<span class='larrow arrow-left'>");
        stringBuilder.push("<i class='arrow-large arrow-large-left'></i>");
        stringBuilder.push("</span>");

        stringBuilder.push("<span class='larrow arrow-right'>");
        stringBuilder.push("<i class='arrow-large arrow-large-right'></i>");
        stringBuilder.push("</span>");
        stringBuilder.push("</div>");

        stringBuilder.push("<div class='view-footer'>");
        stringBuilder.push("<div class='view-abbreviative'>");
        stringBuilder.push("<div class='imageList'>");
        stringBuilder.push("<ul>");
        stringBuilder.push("</ul>");
        stringBuilder.push("</div>");
        stringBuilder.push("</div>");

        stringBuilder.push("<span class='sarrow arrow-left'>");
        stringBuilder.push("<i class='arrow-small arrow-small-left'></i>");
        stringBuilder.push("</span>");

        stringBuilder.push("<span class='sarrow arrow-right'>");
        stringBuilder.push("<i class='arrow-small arrow-small-right'></i>");
        stringBuilder.push("</span>");
        stringBuilder.push("</div>");

        return stringBuilder.join("");
      };

      $this.element = $this._joinElementData();

      //绑定按钮
      var _bindButtons = function() {
        //点击缩略图
        $this.container.on($this.click, ".imgitem", function() {
          var old = $this.container.find(".item-box-focus");
          old.removeClass("item-box-focus");
          $(this).find(".item-box").addClass("item-box-focus");

          $this.container.find(".originalImage").attr("src", $(this).find("img").attr("src"));
          var list = $this.container.find(".imageList");
          var ul = list.find("ul");
          var lis = $this.container.find(".imgitem");

          var a = list.width(); //外层div宽度
          var b = a / 2; //中点
          var h = $this.lWidth; //位移单位
          var c = b - h / 2; //基点
          var d = $(this).position().left; //当前相对位置（相对于ul）
          var e = ul.width(); //ul宽度
          var f = ul.position().left; //ul左侧相对位置（相对于外层div）
          var g = e + f; //ul右侧相对位置（相对于外层div）
          var i = d + f; //当前绝对位置（相对于外层div）

          if(a < e) { //外层div宽度大于ul
            var oIndex = lis.index(old.parent()); //old索引
            var nIndex = lis.index($(this)); //new索引
            var left = 0; //新位置
            var offset = nIndex - oIndex; //位移量

            if(offset > 0) {
              if(i > b) { //ul左移
                if(offset == 1) {
                  if(f <= 0 && f - offset * h <= 0) { //ul左侧相对位置不超过0
                    if(g >= a && g - offset * h >= a) { //ul右侧相对位置超过外层div宽度
                      left = f - h;
                    } else { //重置ul相对位置（靠右）
                      left = a - e;
                    }
                  } else { //重置ul相对位置（靠左）
                    left = 0;
                  }
                } else {
                  var bo = true, os = 1, lt = 0;
                  while(bo) {
                    if(i - os * h <= b) {
                      if(f <= 0 && f - os * h <= 0) { //ul左侧相对位置不超过0
                        if(g >= a && g - os * h >= a) { //ul右侧相对位置超过外层div宽度
                          bo = false;
                          lt = f - os * h;
                          break;
                        } else {
                          bo = false;
                          lt = a - e; //重置ul相对位置（靠右）
                          break;
                        }
                      } else {
                        bo = false;
                        lt = 0; //重置ul相对位置（靠左）
                        break;
                      }
                    }
                    os++;
                  }

                  left = lt;
                }
              } else { //不动
                left = f;
              }
            } else if(offset < 0) {
              if(i < c) { //ul右移
                if(offset == -1) {
                  if(f <= 0 && f - offset * h <= 0) { //ul左侧相对位置不超过0
                    if(g >= a && g - offset * h >= a) { //ul右侧相对位置超过外层div宽度
                      left = f + h;
                    } else { //重置ul相对位置（靠右）
                      left = a - e;
                    }
                  } else { //重置ul相对位置（靠左）
                    left = 0;
                  }
                } else {
                  var bo = true, os = 1, lt = 0;
                  while(bo) {
                    if(i + os * h >= c) {
                      if(f <= 0 && f + os * h <= 0) { //ul左侧相对位置不超过0
                        if(g >= a && g + os * h >= a) { //ul右侧相对位置超过外层div宽度
                          bo = false;
                          lt = f + os * h;
                          break;
                        } else { //重置ul相对位置（靠右）
                          bo = false;
                          lt = a - e;
                          break;
                        }
                      } else { //重置ul相对位置（靠左）
                        bo = false;
                        lt = 0;
                        break;
                      }
                    }
                    os++;
                  }

                  left = lt;
                }
              } else { //不动
                left = f;
              }
            } else { //缩放（居中）
              left = f + c - i;
              if(left > 0) { //ul左侧相对位置不超过0
                left = 0;
              } else if(left + e < a) { //ul右侧相对位置超过外层div宽度
                left = a - e - f;
              }
            }

            ul.css("left", left + "px");
          }
        });

        //点击左箭头 - 大图
        $this.container.on($this.click, ".arrow-large-left", function() {
          $this.container.find(".arrow-small-left").trigger($this.click);
        });

        //点击右箭头 - 大图
        $this.container.on($this.click, ".arrow-large-right", function() {
          $this.container.find(".arrow-small-right").trigger($this.click);
        });

        //点击左箭头 - 小图
        $this.container.on($this.click, ".arrow-small-left", function() {
          var f = $this.container.find(".item-box-focus");
          var p = f.parent().prev();
          if(p && p.length > 0) {
            p.trigger($this.click);
          }
        });

        //点击右箭头 - 小图
        $this.container.on($this.click, ".arrow-small-right", function() {
          var f = $this.container.find(".item-box-focus");
          var p = f.parent().next();
          if(p && p.length > 0) {
            p.trigger($this.click);
          }
        });
      };

      _bindButtons();

      return $this;
    };

    KIT.ImgViewer.prototype.render = function() {
      //绘制

      var $this = this;

      if(rapid.isEmpty($this.options.read.url)) {
        var data = $this.options.data;
        var src = "";
        if(!rapid.isEmpty(data)) {
          var images = [];

          if(rapid.isArray(data)) {
            $this.container.addClass("l-imgviewer-control").attr("unselectable", "on").attr("onselectstart", "return false;");

            for(var i = 0; i < data.length; i++) {
              images.push("<li class='imgitem'>");
              if(i == 0) {
                src = data[i];
                images.push("<div class='item-box item-box-focus'>");
              } else {
                images.push("<div class='item-box'>");
              }

              images.push("<img class='item-img' src='" + data[i] + "' />");
              images.push("</div>");
              images.push("</li>");
            }

            $this.container.append($this.element).find(".view-abbreviative ul").append(images.join(""));
            $this.container.find(".originalImage").attr("src", src);
            $this.lWidth = $this.container.find(".imgitem:first").width() + 8;
            var uWidth = $this.container.find(".imgitem").length * $this.lWidth;
            var iWidth = $this.container.find(".imageList").width();
            if(uWidth <= iWidth) {
              $this.container.find(".imageList ul").css("width", iWidth + "px");
            } else {
              $this.container.find(".imageList ul").css("width", uWidth + "px");
            }

            var _resize = function() {
              var uw = $this.container.find(".imgitem").length * $this.lWidth;
              var iw = $this.container.find(".imageList").width();
              if(uw <= iw) {
                $this.container.find(".imageList ul").css("width", iw + "px").css("left", "0px");
              } else {
                $this.container.find(".imageList ul").css("width", uw + "px");
                $this.container.find(".item-box-focus").parent().trigger($this.click);
              }
            };

            var rt;
            $(window).resize(function() {
              clearTimeout(rt);
              rt = setTimeout(_resize, 150);
            });
          } else {
            $this.container.remove();
            rapid.error("数据格式错误！");
            return false;
          }
        } else {
          $this.container.remove();
        }
      } else {
        rapid.post({
          url: $this.options.read.url,
          data: $this.options.read.params,
          success: function(rs) {
            if(!rapid.isEmpty(rs)) {
              var images = [];

              if(rapid.isArray(rs)) {
                $this.container.addClass("l-imgviewer-control").attr("unselectable", "on").attr("onselectstart", "return false;");

                for(var i = 0; i < rs.length; i++) {
                  images.push("<li class='imgitem'>");
                  if(i == 0) {
                    src = rs[i];
                    images.push("<div class='item-box item-box-focus'>");
                  } else {
                    images.push("<div class='item-box'>");
                  }

                  images.push("<img class='item-img' src='" + rs[i] + "'/>");
                  images.push("</div>");
                  images.push("</li>");
                }

                $this.container.append($this.element).find(".view-abbreviative ul").append(images.join(""));
                $this.container.find(".originalImage").attr("src", src);

                $this.lWidth = $this.container.find(".imgitem:first").width() + 8;
                var uWidth = $this.container.find(".imgitem").length * $this.lWidth;
                var iWidth = $this.container.find(".imageList").width();
                if(uWidth <= iWidth) {
                  $this.container.find(".imageList ul").css("width", iWidth + "px");
                } else {
                  $this.container.find(".imageList ul").css("width", uWidth + "px");
                }

                var _resize = function() {
                  var uw = $this.container.find(".imgitem").length * $this.lWidth;
                  var iw = $this.container.find(".imageList").width();
                  if(uw <= iw) {
                    $this.container.find(".imageList ul").css("width", iw + "px").css("left", "0px");
                  } else {
                    $this.container.find(".imageList ul").css("width", uw + "px");
                    $this.container.find(".item-box-focus").parent().trigger($this.click);
                  }
                };

                var rt;
                $(window).resize(function() {
                  clearTimeout(rt);
                  rt = setTimeout(_resize, 150);
                });

                if(rapid.isFunction($this.options.read.success)) {
                  $this.options.read.success.apply(this, [rs]);
                }
              } else {
                $this.container.remove();
                rapid.error("数据格式错误！");
                return false;
              }
            } else {
              $this.container.remove();
            }
          }
        });
      }

      return $this;
    };
  })();
  //endregion

  //region --------------------> 百度地图控件 - jQuery (lijie)
  (function() {
    KIT.BaiduMap = function(options) {
      var $this = this;
      $this.options = $.extend(true, {}, {
        read: {
          url: "",
          param: {}
        },
        overlay: {
          multiple: false,
          legend: false,
          field: {
            text: "",
            value: ""
          },
          //shapes: [],
          colors: ['#ff0000', '#444444', '#aaaaaa', '#33ccff', '#0000ff', '#cc00cc', '#ccbbff', '#ddff77', '#00aa00', '#008866']
        },
        addressField: "ADDRESS",
        lngField: "LNG",
        latField: "LAT",
        city: "北京市",
        level: 12,
        mapClick: false,
        markerClusterer: {
          cluster: false,
        },
        contents: $.noop,
        cityCall: $.noop
      }, options);

      $this.renderBaiduMap = function() {
        // 百度地图API功能
        var map = new BMap.Map($this.options.id, {enableMapClick: $this.options.mapClick});  //创建地图实例

        var position = $this.options.position;
        var baseLevel = $this.options.level;
        var basePoint = new BMap.Point(position.lng, position.lat);  // 创建点坐标
        map.centerAndZoom(basePoint, baseLevel);  //初始化地图，设置中心点坐标和地图级别
        map.enableScrollWheelZoom();
        map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件

        var datas = $this.options.data;

        var index = 0;
        var opts = {
          width: 200,     // 信息窗口宽度
          title: "详细信息"  // 信息窗口标题
        }

        var pointCollection;
        var points = [];

        //添加覆盖层
        var _addOverlay = function() {
          if($this.options.overlay.multiple) {
            var points = {};
            var legend = {};
            for(var i = 0; i < datas.length; i++) {
              var data = datas[i];
              var valueField = data[$this.options.overlay.field.value];
              if(rapid.isEmpty(points[valueField])) {
                points[valueField] = [];
                if($this.options.overlay.legend) {
                  legend[valueField] = data[$this.options.overlay.field.text];
                }
              }

              points[valueField].push(new BMap.Point(data[$this.options.lngField], data[$this.options.latField]));
            }

            var y = 0;
            for(var p in points) {
              if(y >= $this.options.overlay.colors.length) {
                rapid.error("覆盖物类别数大于填充色总数，请自定义填充色！");
                return false;
              }

              if($this.options.overlay.legend) {
                $this.container.find(".leg_container").append('<p class="leg" tag="l_' + y + '"><span class="leg_icon" style="background-color:' + $this.options.overlay.colors[y] + ';"></span>' + legend[p] + '</p>');
              }

              var o = {
                size: BMAP_POINT_SIZE_NORMAL,
                shape: BMAP_POINT_SHAPE_CIRCLE,
                color: $this.options.overlay.colors[y]
              }

              var pointCollection = new BMap.PointCollection(points[p], o);

              map.addOverlay(pointCollection);

              if($.isFunction($this.options.contents) && !rapid.isEmpty($this.options.contents)) {
                _addPointClickHandler(pointCollection);
              }

              y++;
            }
          } else {
            for(var i = 0; i < datas.length; i++) {
              var data = datas[i];
              points.push(new BMap.Point(data[$this.options.lngField], data[$this.options.latField]));
            }

            var o = {
              size: BMAP_POINT_SIZE_NORMAL,
              shape: BMAP_POINT_SHAPE_CIRCLE,
              color: 'red'
            }

            var pointCollection = new BMap.PointCollection(points, o);
            map.addOverlay(pointCollection);

            if($.isFunction($this.options.contents) && !rapid.isEmpty($this.options.contents)) {
              _addClickHandler(pointCollection);
            }
          }

          _addLegendClickHandler();
        }

        //添加监听事件
        var _addPointClickHandler = function(pointCollection) {
          pointCollection.addEventListener("click", function(e) {
            var p = e.point;
            for(var i = 0; i < datas.length; i++) {
              if(datas[i][$this.options.lngField] == p.lng && datas[i][$this.options.latField] == p.lat) {
                var infoWindow = new BMap.InfoWindow($this.options.contents(datas[i]), opts);  //创建信息窗口对象

                var pt = new BMap.Point(p.lng, p.lat);
                map.openInfoWindow(infoWindow, pt); //开启信息窗口

                break;
              }
            }
          });
        }

        var _addLegendClickHandler = function() {
          $this.container.find(".leg_container .leg").on("click", function() {
            var $this = $(this);
            var tagIndex = $this.attr("tag").split("_")[1];

            if(!rapid.isEmpty(map.getInfoWindow())) {
              map.getInfoWindow().close();
            }

            if($this.hasClass("leg_hide")) {
              $this.removeClass("leg_hide");
              $this.find("span").removeClass("leg_icon_hide");
              map.getOverlays()[tagIndex].wc.hidden = false;
            } else {
              $this.addClass("leg_hide");
              $this.find("span").addClass("leg_icon_hide");
              map.getOverlays()[tagIndex].wc.hidden = true;
            }
          });
        }

        if(datas.length > 0) {
          _addOverlay();
        }
        //创建CityList对象，并放在citylist节点内
        var myCl = new BMapLib.CityList({container: "map_" + $this.options.id + "_citylist", map: map});

        //给城市点击时，添加相关操作
        myCl.addEventListener("cityclick", function(e) {
          // 改当前城市显示
          $this.container.find(".curCity").html(e.name);

          //点击后隐藏城市列表
          $this.container.find(".map_popup").hide();

          if($.isFunction($this.options.cityCall) && !rapid.isEmpty($this.options.cityCall)) {
            $this.options.cityCall(e.name, e.citytype);
          }
        });

        //给“更换城市”链接添加点击操作
        $this.container.find(".curCityText").on("click", function() {
          var cl = $this.container.find(".map_popup");
          if(cl.is(":hidden")) {
            cl.show();
          } else {
            cl.hide();
          }
        });

        // 给城市列表上的关闭按钮添加点击操作
        $this.container.find(".popup_close").on("click", function() {
          var cl = $this.container.find(".map_popup");
          if(cl.is(":hidden")) {
            cl.show();
          } else {
            cl.hide();
          }
        });
      }

      $this.renderCityContainer = function(city) {
        return '<div class="sel_container"><strong class="curCity">'
               + city
               + '</strong>[<a class="curCityText" href="javascript:void(0)">更换城市</a>]</div>'
               + '<div class="map_popup" style="display:none;">'
               + '<div class="popup_main">'
               + '<div class="title">城市列表</div>'
               + '<div class="cityList" id="map_' + $this.options.id + '_citylist"></div>'
               + '<button class="popup_close"></button></div></div>';
      }

      $this.renderLegendContainer = function() {
        return '<div class="leg_container"></div>';
      }

      if($("#" + $this.options.id)) {
        if(rapid.isEmpty($this.options.height)) {
          $this.options.height = $("body").height();
        }

        var baiduMap = "<div id='map_" + $this.options.id + "' class='baiduMap'></div>";
        var div = $("#" + $this.options.id).css("height", $this.options.height);
        var citys = $this.renderCityContainer($this.options.city);
        $("#" + $this.options.id).parent().html($(baiduMap).append(div).append(citys));
        $this.container = $("#map_" + $this.options.id);
        if($this.options.overlay.legend) {
          $this.container.append($this.renderLegendContainer());
        }

        $this.flag = false;
        $this.myGeo = new BMap.Geocoder();
        if(!rapid.isEmpty($this.options.position) && !rapid.isEmpty($this.options.position.lng) && !rapid.isEmpty($this.options.position.lat)) {
          var point = new BMap.Point($this.options.position.lng, $this.options.position.lat);
          $this.myGeo.getLocation(point, function(rs) {
            if(rs) {
              $this.options.city = rs.adress;

              $this.flag = true;
            }
          });
        } else {
          $this.myGeo.getPoint($this.options.city, function(point) {
            if(point) {
              $this.options.position = {
                lng: point.lng,
                lat: point.lat
              }

              $this.flag = true;
            }
          }, $this.options.city);
        }
      }
    };

    KIT.BaiduMap.prototype.render = function() {
      var $this = this;
      var f;
      f = setInterval(function() {
        if($this.flag) {
          clearInterval(f);

          rapid.get({
            url: $this.options.read.url,
            data: $this.options.read.param,
            success: function(rs) {
              if(!rapid.isEmpty(rs) && $.isArray(rs)) {
                $this.options.data = rs;
                $this.renderBaiduMap();
              }
            }
          });
        }
      }, 200);
    };
  })();
  //endregion

  //region --------------------> wangEditor 参数配置（弃用）
  /*(function(WEDITOR) {
   if(!WEDITOR) {
   return;
   }

   // 中文
   WEDITOR.langs['zh-cn'] = {
   bold: '粗体',
   underline: '下划线',
   italic: '斜体',
   forecolor: '文字颜色',
   bgcolor: '背景色',
   strikethrough: '删除线',
   eraser: '清空格式',
   source: '源码',
   quote: '引用',
   fontfamily: '字体',
   fontsize: '字号',
   head: '标题',
   orderlist: '有序列表',
   unorderlist: '无序列表',
   alignleft: '左对齐',
   aligncenter: '居中',
   alignright: '右对齐',
   link: '链接',
   text: '文本',
   submit: '提交',
   cancel: '取消',
   unlink: '取消链接',
   table: '表格',
   emotion: '表情',
   img: '图片',
   video: '视频',
   'width': '宽',
   'height': '高',
   location: '位置',
   loading: '加载中',
   searchlocation: '搜索位置',
   dynamicMap: '动态地图',
   clearLocation: '清除位置',
   langDynamicOneLocation: '动态地图只能显示一个位置',
   insertcode: '插入代码',
   undo: '撤销',
   redo: '重复',
   fullscreen: '全屏',
   openLink: '打开链接'
   };

   // 英文
   WEDITOR.langs.en = {
   bold: 'Bold',
   underline: 'Underline',
   italic: 'Italic',
   forecolor: 'Color',
   bgcolor: 'Backcolor',
   strikethrough: 'Strikethrough',
   eraser: 'Eraser',
   source: 'Codeview',
   quote: 'Quote',
   fontfamily: 'Font family',
   fontsize: 'Font size',
   head: 'Head',
   orderlist: 'Ordered list',
   unorderlist: 'Unordered list',
   alignleft: 'Align left',
   aligncenter: 'Align center',
   alignright: 'Align right',
   link: 'Insert link',
   text: 'Text',
   submit: 'Submit',
   cancel: 'Cancel',
   unlink: 'Unlink',
   table: 'Table',
   emotion: 'Emotions',
   img: 'Image',
   video: 'Video',
   'width': 'width',
   'height': 'height',
   location: 'Location',
   loading: 'Loading',
   searchlocation: 'search',
   dynamicMap: 'Dynamic',
   clearLocation: 'Clear',
   langDynamicOneLocation: 'Only one location in dynamic map',
   insertcode: 'Insert Code',
   undo: 'Undo',
   redo: 'Redo',
   fullscreen: 'Full screnn',
   openLink: 'open link'
   };

   // 全屏时的 z-index
   WEDITOR.config.zindex = 10000;

   // 是否打印log
   WEDITOR.config.printLog = true;

   // 菜单吸顶：false - 不吸顶；number - 吸顶，值为top值
   WEDITOR.config.menuFixed = 0;

   // 编辑源码时，过滤 javascript
   WEDITOR.config.jsFilter = true;

   // 编辑器允许的标签
   WEDITOR.config.legalTags = 'p,h1,h2,h3,h4,h5,h6,blockquote,table,ul,ol,pre';

   // 语言包
   WEDITOR.config.lang = WEDITOR.langs['zh-cn'];

   // 菜单配置
   WEDITOR.config.menus = [
   'source',
   '|',
   'bold',
   'underline',
   'italic',
   'strikethrough',
   'eraser',
   'forecolor',
   'bgcolor',
   '|',
   'quote',
   'fontfamily',
   'fontsize',
   'head',
   'unorderlist',
   'orderlist',
   'alignleft',
   'aligncenter',
   'alignright',
   '|',
   'link',
   'unlink',
   'table',
   'emotion',
   '|',
   'img',
   'video',
   'location',
   'insertcode',
   '|',
   'undo',
   'redo'
   ];

   // 颜色配置
   WEDITOR.config.colors = {
   // 'value': 'title'
   '#880000': '暗红色',
   '#800080': '紫色',
   '#ff0000': '红色',
   '#ff00ff': '鲜粉色',
   '#000080': '深蓝色',
   '#0000ff': '蓝色',
   '#00ffff': '湖蓝色',
   '#008080': '蓝绿色',
   '#008000': '绿色',
   '#808000': '橄榄色',
   '#00ff00': '浅绿色',
   '#ffcc00': '橙黄色',
   '#808080': '灰色',
   '#c0c0c0': '银色',
   '#000000': '黑色',
   '#ffffff': '白色'
   };

   // 字体
   WEDITOR.config.familys = [
   '宋体', '黑体', '楷体', '微软雅黑',
   'Arial', 'Verdana', 'Georgia',
   'Times New Roman', 'Microsoft JhengHei',
   'Trebuchet MS', 'Courier New', 'Impact', 'Comic Sans MS'
   ];

   // 字号
   WEDITOR.config.fontsizes = {
   // 格式：'value': 'title'
   1: '10px',
   2: '13px',
   3: '16px',
   4: '19px',
   5: '22px',
   6: '25px',
   7: '28px'
   };

   // 表情包
   WEDITOR.config.emotionsShow = 'icon'; // 显示项，默认为'icon'，也可以配置成'value'

   WEDITOR.config.emotions = {
   'default': {
   title: '默认',
   data: null//'./emotions.data'
   },
   'weibo': {
   title: '微博表情',
   data: [
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7a/shenshou_thumb.gif',
   value: '[草泥马]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/60/horse2_thumb.gif',
   value: '[神马]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/fuyun_thumb.gif',
   value: '[浮云]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c9/geili_thumb.gif',
   value: '[给力]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f2/wg_thumb.gif',
   value: '[围观]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/70/vw_thumb.gif',
   value: '[威武]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6e/panda_thumb.gif',
   value: '[熊猫]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/81/rabbit_thumb.gif',
   value: '[兔子]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/otm_thumb.gif',
   value: '[奥特曼]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/15/j_thumb.gif',
   value: '[囧]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/89/hufen_thumb.gif',
   value: '[互粉]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c4/liwu_thumb.gif',
   value: '[礼物]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/ac/smilea_thumb.gif',
   value: '[呵呵]'
   },
   {
   icon: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/0b/tootha_thumb.gif',
   value: '[哈哈]'
   }
   ]
   }
   };

   // 百度地图的key
   WEDITOR.config.mapAk = 'TVhjYjq1ICT2qqL5LdS8mwas';

   // 上传图片的配置
   // server地址
   WEDITOR.config.uploadImgUrl = '';
   // 超时时间
   WEDITOR.config.uploadTimeout = 20 * 1000;
   // 用于存储上传回调事件
   WEDITOR.config.uploadImgFns = {};
   // 自定义上传图片的filename
   // E.config.uploadImgFileName = 'customFileName';

   // 自定义上传，设置为 true 之后，显示上传图标
   WEDITOR.config.customUpload = false;
   // 自定义上传的init事件
   // E.config.customUploadInit = function () {....};

   // 自定义上传时传递的参数（如 token）
   WEDITOR.config.uploadParams = {
   /!* token: 'abcdef12345' *!/
   };

   // 自定义上传是的header参数
   WEDITOR.config.uploadHeaders = {
   /!* 'Accept' : 'text/x-json' *!/
   };

   // 是否过滤粘贴内容
   WEDITOR.config.pasteFilter = true;

   // 是否粘贴纯文本，当 editor.config.pasteFilter === false 时候，此配置将失效
   WEDITOR.config.pasteText = false;
   })(window.wangEditor);*/
  //endregion
  //endregion

  // 页面初始化后的操作
  rapid(document).ready(function() {
    var __R_user_id = rapid("#userLoginId");

    if(__R_user_id.length === 1) {
      // 用户id
      RES.SESSION_USER_ID = __R_user_id.val();
      // 用户名称
      RES.SESSION_USER_NAME = rapid("#userLoginName").val();
    }
  });

})(rapid.kit, rapid.res);